package gv.project 
{
	import com.greensock.TweenMax;

	import flash.events.MouseEvent;

	/**
	 * @author rick
	 */
	public class PlantButton extends PlantIcon
	{
		private var icon : PlantIcon;
		private var colorMode : uint;

		public function PlantButton(icon:PlantIcon)
		{
			this.icon = icon;
			buttonMode = true;
			color = 0x00FFFF;
			super();
		}
		
		public function setMode(colorMode : uint) : void
		{
			this.colorMode = colorMode;
			TweenMax.to(this,.5,{colorTransform:{tint:colorMode, tintAmount:.5}});
			removeEventListener(MouseEvent.ROLL_OVER, onMouseOver);
			removeEventListener(MouseEvent.ROLL_OUT, onMouseOut);
			addEventListener(MouseEvent.ROLL_OVER, onMouseOver);
			addEventListener(MouseEvent.ROLL_OUT, onMouseOut);
		}
		
		private function onMouseOut(event : MouseEvent) : void
		{
			TweenMax.to(this,.5,{colorTransform:{tint:colorMode, tintAmount:.5}});
		}

		private function onMouseOver(event : MouseEvent) : void
		{
			TweenMax.to(this,.5,{colorTransform:{tint:colorMode, tintAmount:.8}});
		}

		public function getIconY() : Number
		{
			return icon.ratioY;
		}

		public function getIconX() : Number
		{
			return icon.ratioX;
		}

		override public function setState(i : int) : void
		{
			icon.setState(i);
			super.setState(i);			
		}
		
		public function getIcon() : PlantIcon
		{
			return icon;
		}
	}
}
